package com.coinworld.admin;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportResource;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.client.RestTemplate;

import java.nio.charset.Charset;

@SpringBootApplication
@ImportResource(locations = {"classpath:spring-config/*.xml"})
@ComponentScan(basePackages = {"com.honey.trip"})
@ServletComponentScan()
public class HoneyTripAdminApplication extends SpringBootServletInitializer {

	public static void main(String[] args) {
		SpringApplication.run(HoneyTripAdminApplication.class, args);
	}
	@Override//为了打包springboot项目
	protected SpringApplicationBuilder configure(
			SpringApplicationBuilder builder) {
		return builder.sources(this.getClass());
	}

	@Bean
	public RestTemplate restTemplate(RestTemplateBuilder builder) {
		RestTemplate restTemplate = builder.build();
		restTemplate.getMessageConverters()
				.add(new StringHttpMessageConverter(Charset.forName("utf-8")));
		return restTemplate;
	}

}
